/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package BancoDeDados;

import java.nio.file.Path;
import java.sql.Connection;
import java.sql.Statement;

/**
 * ConexaoDB
 *
 * Versao 1.0
 *
 * Data Criação 22/03/2014
 *
 * @author Igor
 */
public abstract class ConexaoDB {

    //Atributos
    protected Connection con = null;
    protected Statement stm = null;
    protected String driver = "";
    protected Path directoryDB;
    protected String arquivo;
    protected String url = "";
    protected String userNameDB = "";
    protected String passwordDB = "";

    //Construtores
    public ConexaoDB() {
    }

    //Getters e Setters
    /**
     * @return the con
     */
    public Connection getCon() {
        return con;
    }

     /**
     * @param con the con to set
     */
    public void setCon(Connection con) {
        this.con = con;
    }

    /**
     * @return the stm
     */
    public Statement getStm() {
        return stm;
    }

    /**
     * @param stm the stm to set
     */
    public void setStm(Statement stm) {
        this.stm = stm;
    }

    //Outros Metodos
    /**
     * Preenche os campos de conexao, driver, etc, do Banco de Dados
     */
    public void gerenciarConfiguracoes() throws Exception {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    /**
     * Inicializa conexao com o Banco de Dados
     * @throws Exception 
     */
    public void startDB() throws Exception {
        //try {
            setStm(getCon().createStatement());
        /*} catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }*/
    }

    /**
     * Finaliza conexao com o Banco de Dados
     * @throws Exception 
     */
    public void stopDB() throws Exception {
        try {
            getStm().close();
        } catch (Exception e) {
            throw new IllegalArgumentException(e.getMessage());
        }
    }

    /**
     * Restart da conexao com o Banco de Dados
     * @throws Exception 
     */
    public void restartDB() throws Exception {
        stopDB();
        startDB();
    }
}
